package quartz;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author ml
 * @create 2017-11-06--16:35
 */
public class QuartzDemo {

    public static void main(String[] args) throws SchedulerException {
        JobDetail detail= JobBuilder.newJob(MyJob.class)
                .withIdentity("myJob","myGroup")
                .usingJobData("name","majiajia")
                .build();

        Trigger trigger= TriggerBuilder.newTrigger()
                .withIdentity("triggerName","triggerGroup")
                .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInMilliseconds(4).repeatForever())
                .startNow()
                .build();

        SchedulerFactory schedulerFactory=new StdSchedulerFactory();
        Scheduler scheduler=schedulerFactory.getScheduler();
        scheduler.scheduleJob(detail,trigger);
        scheduler.start();
    }
}
